home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / vidhrdw / punchout.c < prev    next >
C/C++ Source or Header  |  2000-05-04  |  22KB  |  792 lines

  1. /***************************************************************************
  2.  
  3.   vidhrdw.c
  4.  
  5.   Functions to emulate the video hardware of the machine.
  6.  
  7. ***************************************************************************/
  8.  
  9. #include "driver.h"
  10. #include "vidhrdw/generic.h"
  11.  
  12.  
  13. #define TOP_MONITOR_ROWS 30
  14. #define BOTTOM_MONITOR_ROWS 30
  15.  
  16. #define BIGSPRITE_WIDTH 128
  17. #define BIGSPRITE_HEIGHT 256
  18. #define ARMWREST_BIGSPRITE_WIDTH 256
  19. #define ARMWREST_BIGSPRITE_HEIGHT 128
  20.  
  21. unsigned char *punchout_videoram2;
  22. size_t punchout_videoram2_size;
  23. unsigned char *punchout_bigsprite1ram;
  24. size_t punchout_bigsprite1ram_size;
  25. unsigned char *punchout_bigsprite2ram;
  26. size_t punchout_bigsprite2ram_size;
  27. unsigned char *punchout_scroll;
  28. unsigned char *punchout_bigsprite1;
  29. unsigned char *punchout_bigsprite2;
  30. unsigned char *punchout_palettebank;
  31. static unsigned char *dirtybuffer2,*bs1dirtybuffer,*bs2dirtybuffer;
  32. static struct osd_bitmap *bs1tmpbitmap,*bs2tmpbitmap;
  33.  
  34. static int top_palette_bank,bottom_palette_bank;
  35.  
  36. static struct rectangle topvisiblearea =
  37. {
  38.     0*8, 32*8-1,
  39.     0*8, (TOP_MONITOR_ROWS-2)*8-1
  40. };
  41. static struct rectangle bottomvisiblearea =
  42. {
  43.     0*8, 32*8-1,
  44.     (TOP_MONITOR_ROWS+2)*8, (TOP_MONITOR_ROWS+BOTTOM_MONITOR_ROWS)*8-1
  45. };
  46. static struct rectangle backgroundvisiblearea =
  47. {
  48.     0*8, 64*8-1,
  49.     (TOP_MONITOR_ROWS+2)*8, (TOP_MONITOR_ROWS+BOTTOM_MONITOR_ROWS)*8-1
  50. };
  51.  
  52.  
  53.  
  54. /***************************************************************************
  55.  
  56.   Convert the color PROMs into a more useable format.
  57.  
  58.   Punch Out has a six 512x4 palette PROMs (one per gun; three for the top
  59.   monitor chars, three for everything else).
  60.   The PROMs are connected to the RGB output this way:
  61.  
  62.   bit 3 -- 240 ohm resistor -- inverter  -- RED/GREEN/BLUE
  63.         -- 470 ohm resistor -- inverter  -- RED/GREEN/BLUE
  64.         -- 1  kohm resistor -- inverter  -- RED/GREEN/BLUE
  65.   bit 0 -- 2  kohm resistor -- inverter  -- RED/GREEN/BLUE
  66.  
  67. ***************************************************************************/
  68. static void convert_palette(unsigned char *palette,const unsigned char *color_prom)
  69. {
  70.     int i;
  71.  
  72.  
  73.     for (i = 0;i < 1024;i++)
  74.     {
  75.         int bit0,bit1,bit2,bit3;
  76.  
  77.  
  78.         bit0 = (color_prom[0] >> 0) & 0x01;
  79.         bit1 = (color_prom[0] >> 1) & 0x01;
  80.         bit2 = (color_prom[0] >> 2) & 0x01;
  81.         bit3 = (color_prom[0] >> 3) & 0x01;
  82.         *(palette++) = 255 - (0x10 * bit0 + 0x21 * bit1 + 0x46 * bit2 + 0x88 * bit3);
  83.         bit0 = (color_prom[1024] >> 0) & 0x01;
  84.         bit1 = (color_prom[1024] >> 1) & 0x01;
  85.         bit2 = (color_prom[1024] >> 2) & 0x01;
  86.         bit3 = (color_prom[1024] >> 3) & 0x01;
  87.         *(palette++) = 255 - (0x10 * bit0 + 0x21 * bit1 + 0x46 * bit2 + 0x88 * bit3);
  88.         bit0 = (color_prom[2*1024] >> 0) & 0x01;
  89.         bit1 = (color_prom[2*1024] >> 1) & 0x01;
  90.         bit2 = (color_prom[2*1024] >> 2) & 0x01;
  91.         bit3 = (color_prom[2*1024] >> 3) & 0x01;
  92.         *(palette++) = 255 - (0x10 * bit0 + 0x21 * bit1 + 0x46 * bit2 + 0x88 * bit3);
  93.  
  94.         color_prom++;
  95.     }
  96.  
  97.     /* reserve the last color for the transparent pen (none of the game colors has */
  98.     /* these RGB components) */
  99.     *(palette++) = 240;
  100.     *(palette++) = 240;
  101.     *(palette++) = 240;
  102. }
  103.  
  104.  
  105. /* these depend on jumpers on the board and change from game to game */
  106. static int gfx0inv,gfx1inv,gfx2inv,gfx3inv;
  107.  
  108. void punchout_vh_convert_color_prom(unsigned char *palette,unsigned short *colortable,const unsigned char *color_prom)
  109. {
  110.     int i;
  111.     #define TOTAL_COLORS(gfxn) (Machine->gfx[gfxn]->total_colors * Machine->gfx[gfxn]->color_granularity)
  112.     #define COLOR(gfxn,offs) (colortable[Machine->drv->gfxdecodeinfo[gfxn].color_codes_start + (offs)])
  113.  
  114.  
  115.     convert_palette(palette,color_prom);
  116.  
  117.  
  118.     /* top monitor chars */
  119.     for (i = 0;i < TOTAL_COLORS(0);i++)
  120.         COLOR(0,i ^ gfx0inv) = i;
  121.  
  122.     /* bottom monitor chars */
  123.     for (i = 0;i < TOTAL_COLORS(1);i++)
  124.         COLOR(1,i ^ gfx1inv) = i + 512;
  125.  
  126.     /* big sprite #1 */
  127.     for (i = 0;i < TOTAL_COLORS(2);i++)
  128.     {
  129.         if (i % 8 == 0) COLOR(2,i ^ gfx2inv) = 1024;    /* transparent */
  130.         else COLOR(2,i ^ gfx2inv) = i + 512;
  131.     }
  132.  
  133.     /* big sprite #2 */
  134.     for (i = 0;i < TOTAL_COLORS(3);i++)
  135.     {
  136.         if (i % 4 == 0) COLOR(3,i ^ gfx3inv) = 1024;    /* transparent */
  137.         else COLOR(3,i ^ gfx3inv) = i + 512;
  138.     }
  139. }
  140.  
  141. void armwrest_vh_convert_color_prom(unsigned char *palette,unsigned short *colortable,const unsigned char *color_prom)
  142. {
  143.     int i;
  144.     #define TOTAL_COLORS(gfxn) (Machine->gfx[gfxn]->total_colors * Machine->gfx[gfxn]->color_granularity)
  145.     #define COLOR(gfxn,offs) (colortable[Machine->drv->gfxdecodeinfo[gfxn].color_codes_start + (offs)])
  146.  
  147.  
  148.     convert_palette(palette,color_prom);
  149.  
  150.  
  151.     /* top monitor / bottom monitor backround chars */
  152.     for (i = 0;i < TOTAL_COLORS(0);i++)
  153.         COLOR(0,i) = i;
  154.  
  155.     /* bottom monitor foreground chars */
  156.     for (i = 0;i < TOTAL_COLORS(1);i++)
  157.         COLOR(1,i) = i + 512;
  158.  
  159.     /* big sprite #1 */
  160.     for (i = 0;i < TOTAL_COLORS(2);i++)
  161.     {
  162.         if (i % 8 == 7) COLOR(2,i) = 1024;    /* transparent */
  163.         else COLOR(2,i) = i + 512;
  164.     }
  165.  
  166.     /* big sprite #2 - pen order is inverted */
  167.     for (i = 0;i < TOTAL_COLORS(3);i++)
  168.     {
  169.         if (i % 4 == 3) COLOR(3,i ^ 3) = 1024;    /* transparent */
  170.         else COLOR(3,i ^ 3) = i + 512;
  171.     }
  172. }
  173.  
  174.  
  175.  
  176. static void gfx_fix(void)
  177. {
  178.     /* one graphics ROM (4v) doesn't */
  179.     /* exist but must be seen as a 0xff fill for colors to come out properly */
  180.     memset(memory_region(REGION_GFX3) + 0x2c000,0xff,0x4000);
  181. }
  182.  
  183. void init_punchout(void)
  184. {
  185.     gfx_fix();
  186.  
  187.     gfx0inv = 0x03;
  188.     gfx1inv = 0xfc;
  189.     gfx2inv = 0xff;
  190.     gfx3inv = 0xfc;
  191. }
  192.  
  193. void init_spnchout(void)
  194. {
  195.     gfx_fix();
  196.  
  197.     gfx0inv = 0x00;
  198.     gfx1inv = 0xff;
  199.     gfx2inv = 0xff;
  200.     gfx3inv = 0xff;
  201. }
  202.  
  203. void init_spnchotj(void)
  204. {
  205.     gfx_fix();
  206.  
  207.     gfx0inv = 0xfc;
  208.     gfx1inv = 0xff;
  209.     gfx2inv = 0xff;
  210.     gfx3inv = 0xff;
  211. }
  212.  
  213. void init_armwrest(void)
  214. {
  215.     gfx_fix();
  216.  
  217.     /* also, ROM 2k is enabled only when its top half is accessed. The other half must */
  218.     /* be seen as a 0xff fill for colors to come out properly */
  219.     memset(memory_region(REGION_GFX2) + 0x08000,0xff,0x2000);
  220. }
  221.  
  222.  
  223.  
  224.  
  225. /***************************************************************************
  226.  
  227.   Start the video hardware emulation.
  228.  
  229. ***************************************************************************/
  230. int punchout_vh_start(void)
  231. {
  232.     if ((dirtybuffer = malloc(videoram_size)) == 0)
  233.         return 1;
  234.     memset(dirtybuffer,1,videoram_size);
  235.  
  236.     if ((dirtybuffer2 = malloc(punchout_videoram2_size)) == 0)
  237.     {
  238.         free(dirtybuffer);
  239.         return 1;
  240.     }
  241.     memset(dirtybuffer2,1,punchout_videoram2_size);
  242.  
  243.     if ((tmpbitmap = osd_create_bitmap(512,480)) == 0)
  244.     {
  245.         free(dirtybuffer);
  246.         free(dirtybuffer2);
  247.         return 1;
  248.     }
  249.  
  250.     if ((bs1dirtybuffer = malloc(punchout_bigsprite1ram_size)) == 0)
  251.     {
  252.         osd_free_bitmap(tmpbitmap);
  253.         free(dirtybuffer);
  254.         free(dirtybuffer2);
  255.         return 1;
  256.     }
  257.     memset(bs1dirtybuffer,1,punchout_bigsprite1ram_size);
  258.  
  259.     if ((bs1tmpbitmap = osd_create_bitmap(BIGSPRITE_WIDTH,BIGSPRITE_HEIGHT)) == 0)
  260.     {
  261.         osd_free_bitmap(tmpbitmap);
  262.         free(dirtybuffer);
  263.         free(dirtybuffer2);
  264.         free(bs1dirtybuffer);
  265.         return 1;
  266.     }
  267.  
  268.     if ((bs2dirtybuffer = malloc(punchout_bigsprite2ram_size)) == 0)
  269.     {
  270.         osd_free_bitmap(tmpbitmap);
  271.         osd_free_bitmap(bs1tmpbitmap);
  272.         free(dirtybuffer);
  273.         free(dirtybuffer2);
  274.         free(bs1dirtybuffer);
  275.         return 1;
  276.     }
  277.     memset(bs2dirtybuffer,1,punchout_bigsprite2ram_size);
  278.  
  279.     if ((bs2tmpbitmap = osd_create_bitmap(BIGSPRITE_WIDTH,BIGSPRITE_HEIGHT)) == 0)
  280.     {
  281.         osd_free_bitmap(tmpbitmap);
  282.         osd_free_bitmap(bs1tmpbitmap);
  283.         free(dirtybuffer);
  284.         free(dirtybuffer2);
  285.         free(bs1dirtybuffer);
  286.         free(bs2dirtybuffer);
  287.         return 1;
  288.     }
  289.  
  290.     return 0;
  291. }
  292.  
  293. int armwrest_vh_start(void)
  294. {
  295.     if ((dirtybuffer = malloc(videoram_size)) == 0)
  296.         return 1;
  297.     memset(dirtybuffer,1,videoram_size);
  298.  
  299.     if ((dirtybuffer2 = malloc(punchout_videoram2_size)) == 0)
  300.     {
  301.         free(dirtybuffer);
  302.         return 1;
  303.     }
  304.     memset(dirtybuffer2,1,punchout_videoram2_size);
  305.  
  306.     if ((tmpbitmap = osd_create_bitmap(512,480)) == 0)
  307.     {
  308.         free(dirtybuffer);
  309.         free(dirtybuffer2);
  310.         return 1;
  311.     }
  312.  
  313.     if ((bs1dirtybuffer = malloc(punchout_bigsprite1ram_size)) == 0)
  314.     {
  315.         osd_free_bitmap(tmpbitmap);
  316.         free(dirtybuffer);
  317.         free(dirtybuffer2);
  318.         return 1;
  319.     }
  320.     memset(bs1dirtybuffer,1,punchout_bigsprite1ram_size);
  321.  
  322.     if ((bs1tmpbitmap = osd_create_bitmap(ARMWREST_BIGSPRITE_WIDTH,ARMWREST_BIGSPRITE_HEIGHT)) == 0)
  323.     {
  324.         osd_free_bitmap(tmpbitmap);
  325.         free(dirtybuffer);
  326.         free(dirtybuffer2);
  327.         free(bs1dirtybuffer);
  328.         return 1;
  329.     }
  330.  
  331.     if ((bs2dirtybuffer = malloc(punchout_bigsprite2ram_size)) == 0)
  332.     {
  333.         osd_free_bitmap(tmpbitmap);
  334.         osd_free_bitmap(bs1tmpbitmap);
  335.         free(dirtybuffer);
  336.         free(dirtybuffer2);
  337.         free(bs1dirtybuffer);
  338.         return 1;
  339.     }
  340.     memset(bs2dirtybuffer,1,punchout_bigsprite2ram_size);
  341.  
  342.     if ((bs2tmpbitmap = osd_create_bitmap(BIGSPRITE_WIDTH,BIGSPRITE_HEIGHT)) == 0)
  343.     {
  344.         osd_free_bitmap(tmpbitmap);
  345.         osd_free_bitmap(bs1tmpbitmap);
  346.         free(dirtybuffer);
  347.         free(dirtybuffer2);
  348.         free(bs1dirtybuffer);
  349.         free(bs2dirtybuffer);
  350.         return 1;
  351.     }
  352.  
  353.     return 0;
  354. }
  355.  
  356.  
  357.  
  358. /***************************************************************************
  359.  
  360.   Stop the video hardware emulation.
  361.  
  362. ***************************************************************************/
  363. void punchout_vh_stop(void)
  364. {
  365.     free(dirtybuffer);
  366.     free(dirtybuffer2);
  367.     free(bs1dirtybuffer);
  368.     free(bs2dirtybuffer);
  369.     osd_free_bitmap(tmpbitmap);
  370.     osd_free_bitmap(bs1tmpbitmap);
  371.     osd_free_bitmap(bs2tmpbitmap);
  372. }
  373.  
  374.  
  375.  
  376. WRITE_HANDLER( punchout_videoram2_w )
  377. {
  378.     if (punchout_videoram2[offset] != data)
  379.     {
  380.         dirtybuffer2[offset] = 1;
  381.  
  382.         punchout_videoram2[offset] = data;
  383.     }
  384. }
  385.  
  386. WRITE_HANDLER( punchout_bigsprite1ram_w )
  387. {
  388.     if (punchout_bigsprite1ram[offset] != data)
  389.     {
  390.         bs1dirtybuffer[offset] = 1;
  391.  
  392.         punchout_bigsprite1ram[offset] = data;
  393.     }
  394. }
  395.  
  396. WRITE_HANDLER( punchout_bigsprite2ram_w )
  397. {
  398.     if (punchout_bigsprite2ram[offset] != data)
  399.     {
  400.         bs2dirtybuffer[offset] = 1;
  401.  
  402.         punchout_bigsprite2ram[offset] = data;
  403.     }
  404. }
  405.  
  406.  
  407.  
  408. WRITE_HANDLER( punchout_palettebank_w )
  409. {
  410.     *punchout_palettebank = data;
  411.  
  412.     if (top_palette_bank != ((data >> 1) & 0x01))
  413.     {
  414.         top_palette_bank = (data >> 1) & 0x01;
  415.         memset(dirtybuffer,1,videoram_size);
  416.     }
  417.     if (bottom_palette_bank != ((data >> 0) & 0x01))
  418.     {
  419.         bottom_palette_bank = (data >> 0) & 0x01;
  420.         memset(dirtybuffer2,1,punchout_videoram2_size);
  421.         memset(bs1dirtybuffer,1,punchout_bigsprite1ram_size);
  422.         memset(bs2dirtybuffer,1,punchout_bigsprite2ram_size);
  423.     }
  424. }
  425.  
  426.  
  427.  
  428. /***************************************************************************
  429.  
  430.   Draw the game screen in the given osd_bitmap.
  431.   Do NOT call osd_update_display() from this function, it will be called by
  432.   the main emulation engine.
  433.  
  434. ***************************************************************************/
  435. void punchout_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh)
  436. {
  437.     int offs;
  438.  
  439.  
  440.     /* for every character in the Video RAM, check if it has been modified */
  441.     /* since last time and update it accordingly. */
  442.     for (offs = videoram_size - 2;offs >= 0;offs -= 2)
  443.     {
  444.         if (dirtybuffer[offs] || dirtybuffer[offs + 1])
  445.         {
  446.             int sx,sy;
  447.  
  448.  
  449.             dirtybuffer[offs] = 0;
  450.             dirtybuffer[offs + 1] = 0;
  451.  
  452.             sx = offs/2 % 32;
  453.             sy = offs/2 / 32;
  454.  
  455.             drawgfx(tmpbitmap,Machine->gfx[0],
  456.                     videoram[offs] + 256 * (videoram[offs + 1] & 0x03),
  457.                     ((videoram[offs + 1] & 0x7c) >> 2) + 64 * top_palette_bank,
  458.                     videoram[offs + 1] & 0x80,0,
  459.                     8*sx,8*sy - 8*(32-TOP_MONITOR_ROWS),
  460.                     &topvisiblearea,TRANSPARENCY_NONE,0);
  461.         }
  462.     }
  463.  
  464.     for (offs = punchout_videoram2_size - 2;offs >= 0;offs -= 2)
  465.     {
  466.         if (dirtybuffer2[offs] | dirtybuffer2[offs + 1])
  467.         {
  468.             int sx,sy;
  469.  
  470.  
  471.             dirtybuffer2[offs] = 0;
  472.             dirtybuffer2[offs + 1] = 0;
  473.  
  474.             sx = offs/2 % 64;
  475.             sy = offs/2 / 64;
  476.  
  477.             drawgfx(tmpbitmap,Machine->gfx[1],
  478.                     punchout_videoram2[offs] + 256 * (punchout_videoram2[offs + 1] & 0x03),
  479.                     ((punchout_videoram2[offs + 1] & 0x7c) >> 2) + 64 * bottom_palette_bank,
  480.                     punchout_videoram2[offs + 1] & 0x80,0,
  481.                     8*sx,8*sy + 8*TOP_MONITOR_ROWS,
  482.                     &backgroundvisiblearea,TRANSPARENCY_NONE,0);
  483.         }
  484.     }
  485.  
  486.     for (offs = punchout_bigsprite1ram_size - 4;offs >= 0;offs -= 4)
  487.     {
  488.         if (bs1dirtybuffer[offs] | bs1dirtybuffer[offs + 1] | bs1dirtybuffer[offs + 3])
  489.         {
  490.             int sx,sy;
  491.  
  492.  
  493.             bs1dirtybuffer[offs] = 0;
  494.             bs1dirtybuffer[offs + 1] = 0;
  495.             bs1dirtybuffer[offs + 3] = 0;
  496.  
  497.             sx = offs/4 % 16;
  498.             sy = offs/4 / 16;
  499.  
  500.             drawgfx(bs1tmpbitmap,Machine->gfx[2],
  501.                     punchout_bigsprite1ram[offs] + 256 * (punchout_bigsprite1ram[offs + 1] & 0x1f),
  502.                     (punchout_bigsprite1ram[offs + 3] & 0x1f) + 32 * bottom_palette_bank,
  503.                     punchout_bigsprite1ram[offs + 3] & 0x80,0,
  504.                     8*sx,8*sy,
  505.                     0,TRANSPARENCY_NONE,0);
  506.         }
  507.     }
  508.  
  509.     for (offs = punchout_bigsprite2ram_size - 4;offs >= 0;offs -= 4)
  510.     {
  511.         if (bs2dirtybuffer[offs] | bs2dirtybuffer[offs + 1] | bs2dirtybuffer[offs + 3])
  512.         {
  513.             int sx,sy;
  514.  
  515.  
  516.             bs2dirtybuffer[offs] = 0;
  517.             bs2dirtybuffer[offs + 1] = 0;
  518.             bs2dirtybuffer[offs + 3] = 0;
  519.  
  520.             sx = offs/4 % 16;
  521.             sy = offs/4 / 16;
  522.  
  523.             drawgfx(bs2tmpbitmap,Machine->gfx[3],
  524.                     punchout_bigsprite2ram[offs] + 256 * (punchout_bigsprite2ram[offs + 1] & 0x0f),
  525.                     (punchout_bigsprite2ram[offs + 3] & 0x3f) + 64 * bottom_palette_bank,
  526.                     punchout_bigsprite2ram[offs + 3] & 0x80,0,
  527.                     8*sx,8*sy,
  528.                     0,TRANSPARENCY_NONE,0);
  529.         }
  530.     }
  531.  
  532.  
  533.     /* copy the character mapped graphics */
  534.     {
  535.         int scroll[64];
  536.  
  537.  
  538.         for (offs = 0;offs < TOP_MONITOR_ROWS;offs++)
  539.             scroll[offs] = 0;
  540.         for (offs = 0;offs < BOTTOM_MONITOR_ROWS;offs++)
  541.             scroll[TOP_MONITOR_ROWS + offs] = -(58 + punchout_scroll[2*offs] + 256 * (punchout_scroll[2*offs + 1] & 0x01));
  542.  
  543.         copyscrollbitmap(bitmap,tmpbitmap,TOP_MONITOR_ROWS + BOTTOM_MONITOR_ROWS,scroll,0,0,&Machine->drv->visible_area,TRANSPARENCY_NONE,0);
  544.     }
  545.  
  546.     /* copy the two big sprites */
  547.     {
  548.         int sx,sy,zoom,height;
  549.  
  550.  
  551.         zoom = punchout_bigsprite1[0] + 256 * (punchout_bigsprite1[1] & 0x0f);
  552.         if (zoom)
  553.         {
  554.             sx = 1024 - (punchout_bigsprite1[2] + 256 * (punchout_bigsprite1[3] & 0x0f)) / 4;
  555.             if (sx > 1024-127) sx -= 1024;
  556.             sx = sx * (0x1000 / 4) / zoom;    /* adjust x position basing on zoom */
  557.             sx -= 57;    /* adjustment to match the screen shots */
  558.  
  559.             sy = -punchout_bigsprite1[4] + 256 * (punchout_bigsprite1[5] & 1);
  560.             sy = sy * (0x1000 / 4) / zoom;    /* adjust y position basing on zoom */
  561.  
  562.             /* when the sprite is reduced, it fits more than */
  563.             /* once in the screen, so if the first draw is */
  564.             /* offscreen the second can be visible */
  565.             height = 256 * (0x1000 / 4) / zoom;    /* height of the zoomed sprite */
  566.             if (sy <= -height+16) sy += 2*height;    /* if offscreen, try moving it lower */
  567.  
  568.             sy += 3;    /* adjustment to match the screen shots */
  569.                 /* have to be at least 3, using 2 creates a blank line at the bottom */
  570.                 /* of the screen when you win the championship and jump around with */
  571.                 /* the belt */
  572.  
  573.             if (punchout_bigsprite1[7] & 1)    /* display in top monitor */
  574.             {
  575.                 copybitmapzoom(bitmap,bs1tmpbitmap,
  576.                         punchout_bigsprite1[6] & 1,0,
  577.                         sx,sy - 8*(32-TOP_MONITOR_ROWS),
  578.                         &topvisiblearea,TRANSPARENCY_COLOR,1024,
  579.                         0x10000 * 0x1000 / 4 / zoom,0x10000 * 0x1000 / 4 / zoom);
  580.             }
  581.             if (punchout_bigsprite1[7] & 2)    /* display in bottom monitor */
  582.             {
  583.                 copybitmapzoom(bitmap,bs1tmpbitmap,
  584.                         punchout_bigsprite1[6] & 1,0,
  585.                         sx,sy + 8*TOP_MONITOR_ROWS,
  586.                         &bottomvisiblearea,TRANSPARENCY_COLOR,1024,
  587.                         0x10000 * 0x1000 / 4 / zoom,0x10000 * 0x1000 / 4 / zoom);
  588.             }
  589.         }
  590.     }
  591.     {
  592.         int sx,sy;
  593.  
  594.  
  595.         sx = 512 - (punchout_bigsprite2[0] + 256 * (punchout_bigsprite2[1] & 1));
  596.         if (sx > 512-127) sx -= 512;
  597.         sx -= 55;    /* adjustment to match the screen shots */
  598.  
  599.         sy = -punchout_bigsprite2[2] + 256 * (punchout_bigsprite2[3] & 1);
  600.         sy += 3;    /* adjustment to match the screen shots */
  601.  
  602.         copybitmap(bitmap,bs2tmpbitmap,
  603.                 punchout_bigsprite2[4] & 1,0,
  604.                 sx,sy + 8*TOP_MONITOR_ROWS,
  605.                 &bottomvisiblearea,TRANSPARENCY_COLOR,1024);
  606.     }
  607. }
  608.  
  609.  
  610. void armwrest_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh)
  611. {
  612.     int offs;
  613.  
  614.  
  615.     /* for every character in the Video RAM, check if it has been modified */
  616.     /* since last time and update it accordingly. */
  617.     for (offs = punchout_videoram2_size - 2;offs >= 0;offs -= 2)
  618.     {
  619.         if (dirtybuffer2[offs] | dirtybuffer2[offs + 1])
  620.         {
  621.             int sx,sy;
  622.  
  623.  
  624.             dirtybuffer2[offs] = 0;
  625.             dirtybuffer2[offs + 1] = 0;
  626.  
  627.             sx = offs/2 % 32;
  628.             sy = offs/2 / 32;
  629.  
  630.             if (sy >= 32)
  631.             {
  632.                 /* top screen */
  633.                 sy -= 32;
  634.                 drawgfx(tmpbitmap,Machine->gfx[0],
  635.                         punchout_videoram2[offs] + 256 * (punchout_videoram2[offs + 1] & 0x03) +
  636.                                 8 * (punchout_videoram2[offs + 1] & 0x80),
  637.                         ((punchout_videoram2[offs + 1] & 0x7c) >> 2) + 64 * top_palette_bank,
  638.                         0,0,
  639.                         8*sx,8*sy - 8*(32-TOP_MONITOR_ROWS),
  640.                         &topvisiblearea,TRANSPARENCY_NONE,0);
  641.             }
  642.             else
  643.                 /* bottom screen background */
  644.                 drawgfx(tmpbitmap,Machine->gfx[0],
  645.                         punchout_videoram2[offs] + 256 * (punchout_videoram2[offs + 1] & 0x03),
  646.                         128 + ((punchout_videoram2[offs + 1] & 0x7c) >> 2) + 64 * bottom_palette_bank,
  647.                         punchout_videoram2[offs + 1] & 0x80,0,
  648.                         8*sx,8*sy + 8*TOP_MONITOR_ROWS,
  649.                         &backgroundvisiblearea,TRANSPARENCY_NONE,0);
  650.         }
  651.     }
  652.  
  653.     for (offs = punchout_bigsprite1ram_size - 4;offs >= 0;offs -= 4)
  654.     {
  655.         if (bs1dirtybuffer[offs] | bs1dirtybuffer[offs + 1] | bs1dirtybuffer[offs + 3])
  656.         {
  657.             int sx,sy;
  658.  
  659.  
  660.             bs1dirtybuffer[offs] = 0;
  661.             bs1dirtybuffer[offs + 1] = 0;
  662.             bs1dirtybuffer[offs + 3] = 0;
  663.  
  664.             sx = offs/4 % 16;
  665.             sy = offs/4 / 16;
  666.             if (sy >= 16)
  667.             {
  668.                 sy -= 16;
  669.                 sx += 16;
  670.             }
  671.  
  672.             drawgfx(bs1tmpbitmap,Machine->gfx[2],
  673.                     punchout_bigsprite1ram[offs] + 256 * (punchout_bigsprite1ram[offs + 1] & 0x1f),
  674.                     (punchout_bigsprite1ram[offs + 3] & 0x1f) + 32 * bottom_palette_bank,
  675.                     punchout_bigsprite1ram[offs + 3] & 0x80,0,
  676.                     8*sx,8*sy,
  677.                     0,TRANSPARENCY_NONE,0);
  678.         }
  679.     }
  680.  
  681.     for (offs = punchout_bigsprite2ram_size - 4;offs >= 0;offs -= 4)
  682.     {
  683.         if (bs2dirtybuffer[offs] | bs2dirtybuffer[offs + 1] | bs2dirtybuffer[offs + 3])
  684.         {
  685.             int sx,sy;
  686.  
  687.  
  688.             bs2dirtybuffer[offs] = 0;
  689.             bs2dirtybuffer[offs + 1] = 0;
  690.             bs2dirtybuffer[offs + 3] = 0;
  691.  
  692.             sx = offs/4 % 16;
  693.             sy = offs/4 / 16;
  694.  
  695.             drawgfx(bs2tmpbitmap,Machine->gfx[3],
  696.                     punchout_bigsprite2ram[offs] + 256 * (punchout_bigsprite2ram[offs + 1] & 0x0f),
  697.                     (punchout_bigsprite2ram[offs + 3] & 0x3f) + 64 * bottom_palette_bank,
  698.                     punchout_bigsprite2ram[offs + 3] & 0x80,0,
  699.                     8*sx,8*sy,
  700.                     0,TRANSPARENCY_NONE,0);
  701.         }
  702.     }
  703.  
  704.  
  705.     /* copy the character mapped graphics */
  706.     copybitmap(bitmap,tmpbitmap,0,0,0,0,&Machine->drv->visible_area,TRANSPARENCY_NONE,0);
  707.  
  708.  
  709.     /* copy the two big sprites */
  710.     {
  711.         int sx,sy,zoom,height;
  712.  
  713.  
  714.         zoom = punchout_bigsprite1[0] + 256 * (punchout_bigsprite1[1] & 0x0f);
  715.         if (zoom)
  716.         {
  717.             sx = 1024 - (punchout_bigsprite1[2] + 256 * (punchout_bigsprite1[3] & 0x0f)) / 4;
  718.             if (sx > 1024-127) sx -= 1024;
  719.             sx = sx * (0x1000 / 4) / zoom;    /* adjust x position basing on zoom */
  720.             sx -= 57;    /* adjustment to match the screen shots */
  721.  
  722.             sy = -punchout_bigsprite1[4] + 256 * (punchout_bigsprite1[5] & 1);
  723.             sy = sy * (0x1000 / 4) / zoom;    /* adjust y position basing on zoom */
  724.  
  725.             /* when the sprite is reduced, it fits more than */
  726.             /* once in the screen, so if the first draw is */
  727.             /* offscreen the second can be visible */
  728.             height = 256 * (0x1000 / 4) / zoom;    /* height of the zoomed sprite */
  729.             if (sy <= -height+16) sy += 2*height;    /* if offscreen, try moving it lower */
  730.  
  731.             sy += 3;    /* adjustment to match the screen shots */
  732.                 /* have to be at least 3, using 2 creates a blank line at the bottom */
  733.                 /* of the screen when you win the championship and jump around with */
  734.                 /* the belt */
  735.  
  736.             if (punchout_bigsprite1[7] & 1)    /* display in top monitor */
  737.             {
  738.                 copybitmapzoom(bitmap,bs1tmpbitmap,
  739.                         punchout_bigsprite1[6] & 1,0,
  740.                         sx,sy - 8*(32-TOP_MONITOR_ROWS),
  741.                         &topvisiblearea,TRANSPARENCY_COLOR,1024,
  742.                         0x10000 * 0x1000 / 4 / zoom,0x10000 * 0x1000 / 4 / zoom);
  743.             }
  744.             if (punchout_bigsprite1[7] & 2)    /* display in bottom monitor */
  745.             {
  746.                 copybitmapzoom(bitmap,bs1tmpbitmap,
  747.                         punchout_bigsprite1[6] & 1,0,
  748.                         sx,sy + 8*TOP_MONITOR_ROWS,
  749.                         &bottomvisiblearea,TRANSPARENCY_COLOR,1024,
  750.                         0x10000 * 0x1000 / 4 / zoom,0x10000 * 0x1000 / 4 / zoom);
  751.             }
  752.         }
  753.     }
  754.     {
  755.         int sx,sy;
  756.  
  757.  
  758.         sx = 512 - (punchout_bigsprite2[0] + 256 * (punchout_bigsprite2[1] & 1));
  759.         if (sx > 512-127) sx -= 512;
  760.         sx -= 55;    /* adjustment to match the screen shots */
  761.  
  762.         sy = -punchout_bigsprite2[2] + 256 * (punchout_bigsprite2[3] & 1);
  763.         sy += 3;    /* adjustment to match the screen shots */
  764.  
  765.         copybitmap(bitmap,bs2tmpbitmap,
  766.                 punchout_bigsprite2[4] & 1,0,
  767.                 sx,sy + 8*TOP_MONITOR_ROWS,
  768.                 &bottomvisiblearea,TRANSPARENCY_COLOR,1024);
  769.     }
  770.  
  771.  
  772.     /* draw the foregound chars */
  773.     for (offs = videoram_size - 2;offs >= 0;offs -= 2)
  774.     {
  775.         int sx,sy;
  776.  
  777.  
  778.         dirtybuffer[offs] = 0;
  779.         dirtybuffer[offs + 1] = 0;
  780.  
  781.         sx = offs/2 % 32;
  782.         sy = offs/2 / 32;
  783.  
  784.         drawgfx(bitmap,Machine->gfx[1],
  785.                 videoram[offs] + 256 * (videoram[offs + 1] & 0x07),
  786.                 ((videoram[offs + 1] & 0xf8) >> 3) + 32 * bottom_palette_bank,
  787.                 videoram[offs + 1] & 0x80,0,
  788.                 8*sx,8*sy + 8*TOP_MONITOR_ROWS,
  789.                 &backgroundvisiblearea,TRANSPARENCY_PEN,7);
  790.     }
  791. }
  792.